package sky.com.command
{
	import com.adobe.cairngorm.business.Responder;
	import com.adobe.cairngorm.commands.ICommand;
	import com.adobe.cairngorm.control.CairngormEvent;
	
	import flash.events.Event;
	import flash.events.EventDispatcher;
	import flash.events.IOErrorEvent;
	
	import mx.controls.Alert;
	
	import sky.com.business.LoginDelegate;
	import sky.com.events.LoginResultEvent;
	import sky.com.model.LoginModel;
	import sky.com.vo.User;
	import mx.core.FlexGlobals;
	
	public class LoginCommand implements ICommand,Responder 
	{

		private var loginModel:LoginModel=LoginModel.getInstance();
		
		public function LoginCommand()
		{
		}
		
		public function execute(event:CairngormEvent):void
		{
			var loginDelegate:LoginDelegate=new LoginDelegate(this);
			var user:User=event.data as User;
			loginDelegate.checkLogin(user);
			//Alert.show(user.userName);
			//Alert.show(user.passWord);
			
		}
		
		public function onResult(event : * = null):void
		{
			var result:Boolean=event as Boolean;
			//loginModel.loginState=1;
			FlexGlobals.topLevelApplication.loginSuccessFun();
			
			
			//Alert.show(String(result));
			//dispatchEvent(new LoginResultEvent());
			//this.dispatchEvent(new LoginResultEvent());
			
		}
		
		public function onFault(event : * = null):void
		{
			
		}
	}
}